﻿#ifndef SCREENSCUTCHEONMANAGER_H
#define SCREENSCUTCHEONMANAGER_H

#include "screenscutcheon.h"


            class  CScutcheonMap : public EarthView::World::Core::CBaseObject
            {

            public:

                /// <summary>
                /// 默认构造函数
                /// </summary>
                CScutcheonMap();

                /// <summary>
                /// 添加图元
                /// </summary>
                /// <param name="key">键</param>
                /// <param name="val">图元</param>
                ev_bool push(const EVString &key, CScreenScutcheon *const &val);

                /// <summary>
                /// 是否存在指定键的图元
                /// </summary>
                /// <param name="key">键</param>
                /// <returns>是否存在</returns>
                ev_bool exist(const EVString &key) const;

                /// </summary>
                /// 获取图元
                /// </summary>
                /// <param name="key">键</param>
                /// <returns>图元的引用</returns>
                CScreenScutcheon*& operator[](const EVString &key) ;

                /// </summary>
                /// 获取图元
                /// </summary>
                /// <param name="key">键</param>
                /// <returns>图元的引用</returns>
                CScreenScutcheon*& get(const EVString &key) ;

                /// </summary>
                /// 删除指定键的图元
                /// </summary>
                /// <param name="key">键</param>
                void erase(const EVString &key);

                /// </summary>
                /// 获取元素数目
                /// </summary>
                /// <returns>元素数目</returns>
                ev_size_t size() const;

                /// </summary>
                /// 清空元素
                /// </summary>
                void clear();

                /// </summary>
                /// 获取是否为空
                /// </summary>
                /// <returns>是否为空</returns>
                ev_bool empty() const;

ev_private:
                typedef std::map<EVString, CScreenScutcheon*> InternalList;
                typedef InternalList::iterator iterator;
                typedef InternalList::const_iterator const_iterator;
                typedef InternalList::reverse_iterator reverse_iterator;
                typedef InternalList::const_reverse_iterator const_reverse_iterator;
                typedef InternalList::mapped_type mapped_type;
                typedef InternalList::key_type key_type;
                typedef InternalList::value_type value_type;
                typedef pair<InternalList::iterator, bool> _Pairib;
                RESERVE_CONTAINER_FUNCTION_MAP(mList);
                _Pairib insert(const value_type &val);
                iterator find(const EVString &key);
                const_iterator find(const EVString &key) const;
            private:
                InternalList mList;
            };

            class  CScreenScutcheonManager : public EarthView::World::Core::CAllocatedObject
            {

      public:

                /// <summary>
                /// 构造函数
                /// </summary>
                CScreenScutcheonManager();
                /// <summary>
                /// 析构函数
                /// </summary>
                ~CScreenScutcheonManager();
                /// <summary>
                ///通过名称，获取CScreenScutcheon对象
                /// </summary>
                /// <param name="name">CScreenScutcheon对象名称</param>
                /// <returns>CScreenScutcheon对象 </returns>	
                CScreenScutcheon* operator[](const EVString& name) ;
                /// <summary>
                ///通过名称，获取CScreenScutcheon对象
                /// </summary>
                /// <param name="name">CScreenScutcheon对象名称</param>
                /// <returns>CScreenScutcheon对象 </returns>	
                CScreenScutcheon* getScutcheon(const EVString& name);
                /// <summary>
                ///从容器中移除CScreenScutcheon对象
                /// </summary>
                /// <param name="name">CScreenScutcheon对象名称</param>
                void removeScutcheon(const EVString& name);
                /// <summary>
                ///从容器中移除所有的CScreenScutcheon对象
                /// </summary>
                void removeAll();
                /// <summary>
                ///释放CScreenScutcheon对象
                /// </summary>
                void destoryScutcheon(const EVString& name);
                /// <summary>
                ///释放所有的CScreenScutcheon对象
                /// </summary>
                void destoryAll();
                /// <summary>
                ///创建CScreenScutcheon对象
                /// </summary>
                /// <param name="name">CScreenScutcheon对象名称</param>
                /// <param name="templateName">模板名称</param>
                /// <param name="styleId">样式ID</param>
                /// <param name="control">EarthView::World::Spatial3D::Controls::CGlobeControl对象</param>
                /// <returns>CScreenScutcheon对象 </returns>	
                CScreenScutcheon* createScutcheon(const EVString& name, const EVString& templateName, 
                     EarthView::World::Spatial3D::Controls::CGlobeControl* control);
                /// <summary>
                ///容器中是否存在CScreenScutcheon对象
                /// </summary>
                /// <returns>是否存在</returns>	
                bool exist(const EVString& name) ;
                /// <summary>
                ///单件模式获取CScreenScutcheonManager对象
                /// </summary>
                static CScreenScutcheonManager& getSingleton();
                /// <summary>
                ///单件模式获取CScreenScutcheonManager指针
                /// </summary>
                static CScreenScutcheonManager* getSingletonPtr();
                /// <summary>
                ///获取容器
                /// </summary>
                CScutcheonMap getScutcheonMap() const;
                /// <summary>
                ///统一设置容器中对象的可见性
                /// </summary>
                void setVisible(const bool& value);

            protected:

                CScutcheonMap mScutcheonMap;
                static CScreenScutcheonManager* mpSingleton;
                CScreenScutcheon* mpScutcheon;
            };

#endif

